package string;

import java.util.Random;
import java.util.UUID;

public class Method2 {
    //上传文件
    public static void main(String[] args) {
        String str="abcdefghijklmnopqrstuvwxyz";

        System.out.println(str.toUpperCase());
        String[] suffixs = {".png", ".jpg", ".gif"};
        String file = "11234.jpg";
        boolean flag = false;
        for (String suffix : suffixs) {
//            suffix.equals(file);
//            suffix.contains(file);
            if (file.endsWith(suffix)) {
                flag = true;
                break;
            }
        }
        if (flag) {
            System.out.println("是图片格式");
            String suffix = file.substring(file.lastIndexOf("."));
            //文件名随机处理(UUID，随机数，随机多少位字母)
            String s = UUID.randomUUID().toString();//生成32位永不重复的字符串
            String s1 = System.currentTimeMillis() + "";//毫秒数

            System.out.println(UUID.randomUUID() + suffix);

        } else {
            System.out.println("不是图片格式");
        }

    }

    public static void random(int length) {
        StringBuilder ret = new StringBuilder();
        Random r = new Random();
        for (int i = 0; i < length; i++) {
            int j = r.nextInt(26)+97;
            ret.append((char) j);
        }

        System.out.println(ret);
    }
}
